-- @owner: lihongji
-- @date: 2022/07/26
-- @testpoint: 数组类型的测试，数组的值成功，数组合理报错

--step1:建表;expect:成功
drop table if exists t_var_pop_samp_variance;
create table t_var_pop_samp_variance(
  col_1 integer,
  col_2 bigint,
  col_3 float8,
  col_4 decimal(12,6),
  col_5 bool,
  col_6 char(30),
  col_7 varchar2(50),
  col_8 varchar(30),
  col_9 interval day to second,
  col_10 timestamp,
  col_11 date,
  col_12 date,
  col_13 timestamp without time zone,
  col_14 blob,
  col_15 clob,
  col_16 int[]
) with (storage_type=ustore);

--step2:创建序列;expect:成功
drop sequence if exists pop_samp_variance_seq_avgx;
create sequence pop_samp_variance_seq_avgx increment by 1 start with 10;

--step3:清空数据后插入数据;expect:成功
truncate table t_var_pop_samp_variance;
begin
 for i in 1..50 loop
  insert into t_var_pop_samp_variance values(
  i,
  pop_samp_variance_seq_avgx.nextval+i,
  i+445.255,
  98*0.99*i,
  true,
  lpad('abc','30','@')::varchar,
  lpad('abc','50','b')::varchar2,
  lpad('abc','30','@')::varchar,
  (interval '4 5:12:10.222' day to second(3)),
  to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),
  to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),
  to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),
  to_timestamp('2019-01-03 14:58:54.000000','yyyy-mm-dd hh24:mi:ss.ffffff'),
  lpad('10','12','01010')::blob,
  rpad('abc','9','a@123&^%djgk')::clob,
  '{32,535,5645645,6767,76,67,56,48,979,978,7}'
  );
 end loop;
end;
/
insert into t_var_pop_samp_variance select * from t_var_pop_samp_variance;
insert into t_var_pop_samp_variance select * from t_var_pop_samp_variance;

--step4:数组的值;expect:成功
select regr_avgx(col_16[3]+col_16[1]+col_1,col_16[3]+col_16[1]+col_1) from t_var_pop_samp_variance order by 1;

--step5:数组;expect:合理报错
select regr_avgx(col_16,col_16) from t_var_pop_samp_variance order by 1;

--step6:清理环境;expect:成功
drop sequence if exists pop_samp_variance_seq_avgx;
drop table if exists t_var_pop_samp_variance cascade;